package com.kehutong.charge.admin;

import com.kehutong.charge.entity.ChargeBillConfig;
import com.kehutong.charge.job.ChargeBillHouseJob;
import com.kehutong.charge.service.ChargeBillConfigService;
import com.kehutong.common.errcode.Result;
import org.coraframework.authz.HasPermission;
import org.coraframework.inject.Inject;
import org.coraframework.logger.Logger;
import org.coraframework.logger.LoggerFactory;
import org.coraframework.mvc.MvcAction;
import org.coraframework.mvc.http.ReqMapping;

import java.util.Map;

@MvcAction
@ReqMapping("/admin/pay/charge/bill/config")
public class ChargeBillConfigController {

    private static final Logger logger = LoggerFactory.getLogger(ChargeBillConfigController.class);

    @Inject
    private ChargeBillConfigService chargeBillConfigService;

    @ReqMapping("/get")
    @HasPermission("pay:charge:bill:mange:view")
    public Object get(String communityNo, String billYearMonth) throws Exception {
        ChargeBillConfig result = chargeBillConfigService.get(communityNo, billYearMonth);
        return Result.success(result);
    }

    @ReqMapping("/generateHouseBill")
    @HasPermission("pay:charge:bill:mange:view")
    public Object generateHouseBill(String billDate) throws Exception {
        Map<String, Integer> result = ChargeBillHouseJob.generateHouseBill(billDate);
        return Result.success(result);
    }

}
